package io.github.cunyu1943;

import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 *
 * @Package : io.github.cunyu1943
 * @ClassName : GuessNum.java
 * @CreateTime : 2022/11/27 22:39
 * @Version : 1.0
 * @Author : 村雨遥
 * @Email : 747731461@qq.com
 * @公众号 : 村雨遥
 * @Website : https://cunyu1943.github.io/JavaPark
 * @Description : 猜数小游戏
 */
public class GuessNum {
    public static void main(String[] args) {
        Random rand = new Random();
        int num = rand.nextInt(100) + 1;

        Scanner scanner = new Scanner(System.in);

        while (true) {
            System.out.println("输入你猜的数");
            int tmp = scanner.nextInt();
            if (num == tmp) {
                System.out.println("你猜对了");
                break;
            } else if (num < tmp) {
                System.out.println("你猜大了，再猜");
            } else {
                System.out.println("你猜小了，再猜");
            }
        }
    }
}
